/* eslint valid-jsdoc: "off" */

'use strict';

const router = require("../app/router");

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1622547261784_554';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  // 关闭csrf验证用于跨域
  config.security = {
    csrf: {
      enable: false,
    },
  };
  // 跨域请求
  config.cors = {
    origin: '*',
    allowMethods: 'GET,POST,PUT,DELETE,HEAD,PATCH',
  };
  config.sequelize = {
    // 数据库类型
    dialect: 'mysql',
    // 连接数据库的名称
    database: 'studentlibrary',
    // 数据库地址
    host: 'localhost',
    // 数据路端口
    port: 3306,
    username: 'root',
    password: 'qazplm123',
    timezone: '+08:00',
    dialectOptions: {
      dateStrings: true,
      typeCast(field, next) {
        if (field.type === "DATETIME") {
          return field.string();
        }
        return next();
      }
    },
  };
  // jwt秘钥
  config.jwt = { secret: 'Myong' };
  return {
    ...config,
    ...userConfig,
  };
};
